"""
lock = threading.Lock()
lock.acquire()
操作的数据
lock.release()
"""

import threading

lock_number = 0
COUNT = 10000000
lock = threading.Lock()


def increase():
    global lock_number
    for i in range(COUNT):
        lock.acquire()
        lock_number += 1
        lock.release()


def decrease():
    global lock_number
    for i in range(COUNT):
        lock.acquire()
        lock_number -= 1
        lock.release()


if __name__ == '__main__':
    t1 = threading.Thread(target=increase)
    t2 = threading.Thread(target=decrease)
    t1.start()
    t2.start()
    t1.join()
    t2.join()
    print("lock_number:", lock_number)
